import execjs
from PIL import Image
from io import BytesIO

class verifycode:
    def crack(self, image):
        img = Image.open(BytesIO(image))
        img_alpha = img.convert('RGBA')
        pixels = list(img_alpha.getdata())
        l = []
        for p in pixels:
            for i in p:
                l.append(i)

        with open('./QiangZhi/VerCode/vercode.js', encoding='utf-8') as f:
            js = execjs.compile(f.read())
            return js.call('crack', l)
